import request from '@/utils/request'
import downloadService from "@/utils/downloadService";

export function login(userName, password, authCode) {
  const data = {
    userName,
    password,
    authCode
  }
  return request({
    url: '/user/login',
    method: 'post',
    headers: {
      isToken: false
    },
    data
  })
}

export function validUser(name, type){
  return request({
    url: '/user/validUsername',
    method: 'get',
    headers: {
      isToken: false
    },
    params: {
      userName: name,
      type: type
    }
  })
}

export function getAuthCode(){
  return request({
    url: '/user/authCode',
    method: 'get',
    headers: {
      isToken: false
    },
    responseType: 'blob'
  })
}

export function getInfo(token) {
  return request({
    url: '/user/getInfo',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/user/logout',
    method: 'post'
  })
}
